home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kwindowinfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-08  |  3.9 KB  |  146 lines

  1. // -*- c++ -*-
  2.  
  3. /*
  4.  *   copyright            : (C) 2001-2002 by Richard Moore
  5.  *   License              : This file is released under the terms of the LGPL, version 2.
  6.  *   email                : rich@kde.org
  7.  */
  8.  
  9. #ifndef KWINDOWINFO_H
  10. #define KWINDOWINFO_H
  11.  
  12. #include <qobject.h>
  13. #include <qpixmap.h>
  14. #include <qstring.h>
  15.  
  16. #include <kdelibs_export.h>
  17.  
  18. /**
  19.  * Displays messages in the window icon and title. The message is usually
  20.  * transient with the original title and icon being restored automatically
  21.  * after a specified time. The simplest use displays a text message in the
  22.  * window title:
  23.  * \code
  24.  *    KWindowInfo::showMessage( this, i18n("Message Body") );
  25.  * \endcode
  26.  * This more complex example changes the window icon, as well as
  27.  * displaying the text. In addition, this example overrides the
  28.  * default timeout to ensure the message is only displayed for 1
  29.  * second.
  30.  * \code
  31.  *    QPixmap px;
  32.  *    px.load( "lo16-app-logtracker.png" );
  33.  *    KWindowInfo::showMessage( this, i18n("Message Body"), px, 1000 );
  34.  * \endcode
  35.  * If the parent window inherits KSystemTray then KWindowInfo changes the
  36.  * pixmap and tooltip of the system window to display the message.
  37.  *
  38.  * @author Richard Moore, rich@kde.org
  39.  * @since 3.1
  40. */
  41. class KDEUI_EXPORT KWindowInfo : public QObject
  42. {
  43.     Q_OBJECT
  44.  
  45. public:
  46.     /**
  47.      * Creates a KWindowInfo with the specified parent.
  48.      */
  49.     KWindowInfo( QWidget *parent, const char *name=0 );
  50.  
  51.     /**
  52.      * Cleans up.
  53.      */
  54.     virtual ~KWindowInfo();
  55.  
  56.     /**
  57.      * Returns true iff the object should delete itself when it resets.
  58.      */
  59.     bool autoDelete() const { return autoDel; }
  60.  
  61.     /**
  62.      * Set to true if you want the object to delete itself when the message
  63.      * timeout occurs.
  64.      */
  65.     void setAutoDelete( bool enable ) { autoDel = enable; }
  66.  
  67.     /**
  68.      * Utility method to display a title bar message for the specified
  69.      * window.
  70.      */
  71.     static void showMessage( QWidget *window, const QString &text, int timeout = -1 );
  72.  
  73.     /**
  74.      * Utility method to display a title bar message and icon for the
  75.      * specified window.
  76.      */
  77.     static void showMessage( QWidget *window, const QString &text,
  78.                  const QPixmap &pix, int timeout = -1 );
  79.  
  80. public slots:
  81.     /**
  82.      * Shows the specified text in the window title.
  83.      */
  84.     void message( const QString &text );
  85.  
  86.     /**
  87.      * Shows the specified text in the window title, and sets the window icon.
  88.      */
  89.     void message( const QString &text, const QPixmap &pix );
  90.  
  91.     /**
  92.      * Shows the specified text in the window title for the specified time.
  93.      */
  94.     void message( const QString &text, int timeout );
  95.  
  96.     /**
  97.      * Shows the specified icon and text in the window title and WM
  98.      * icon, for the specified time. The time is a delay specified in
  99.      * milliseconds, or one of the two special values. The special
  100.      * values are -1 which means the default timeout should be used,
  101.      * and 0 which means the message is permanent.
  102.      */
  103.     void message( const QString &text, const QPixmap &pix, int timeout );
  104.  
  105.     /**
  106.      * Shows the specified text in the window title with no timeout.
  107.      */
  108.     void permanent( const QString &text );
  109.  
  110.     /**
  111.      * Shows the specified text and icon in the window title with no timeout.
  112.      */
  113.     void permanent( const QString &text, const QPixmap &pix );
  114.  
  115. protected:
  116.     /**
  117.      * Displays the message in the titlebar/icon.
  118.      */
  119.     virtual void display( const QString &text, const QPixmap &pix );
  120.  
  121. protected slots:
  122.     /**
  123.      * Saves the window title and icon.
  124.      */
  125.     virtual void save();
  126.  
  127.     /**
  128.      * Resets the window title and icon to the saved values. If
  129.      * auto-delete is enabled then the object is deleted.
  130.      */
  131.     virtual void restore();
  132.  
  133. private:
  134.     QWidget *win;
  135.     QPixmap oldIcon;
  136.     QPixmap oldMiniIcon;
  137.     QString oldText;
  138.     bool autoDel;
  139.  
  140.     /* @internal */
  141.     class Private *d;
  142. };
  143.  
  144. #endif // KWINDOWINFO_H
  145.  
  146.